#include<stdio.h>
int judge(int l,int k,int y);
int main()
{
	int a,b,c,n,i,min=999,sum=0;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	getchar();
	for(i=0;i<n;i++)
	{   
	    sum=judge(a,b,c);
		if(min>sum)
		min = sum;
	}
	printf("%d\n",min);
	return 0;
}
int judge(int l,int k,int y)
{
	int i,m=0,s;
	for(i=0;i<999;i++)
	{   s=getchar();
		if(s=='A')
		m=m+l+k+y;
		if(s=='B')
		m=m+2*l+k;
		if(s=='C')
		m=m+3*l+3*k+2*y;
		if(s=='\n')
		break;	
	}
	return m;
}
